﻿using Prism.Commands;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Loaf.自定义控件.Controls
{
    public class NavigationItem : Control
    {
        public static DependencyProperty IsSelectedProperty = DependencyProperty.Register(nameof(IsSelected), typeof(bool), typeof(NavigationItem), new PropertyMetadata(false));
        public static DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(NavigationItem), new PropertyMetadata(""));
        public static DependencyProperty CommandProperty = DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(NavigationItem), new PropertyMetadata(null));
        public static DependencyProperty CommandParameterProperty = DependencyProperty.Register(nameof(CommandParameter), typeof(string), typeof(NavigationItem), new PropertyMetadata(null));


        /// <summary>
        /// 是否被选中
        /// </summary>
        public bool IsSelected { get => (bool)GetValue(IsSelectedProperty); set => SetValue(IsSelectedProperty, value); }
        /// <summary>
        /// 导航子项的显示标题
        /// </summary>
        public string Header { get => (string)GetValue(HeaderProperty); set => SetValue(HeaderProperty, value); }
        /// <summary>
        /// 供 Navigation 类中使用，触发点击事件
        /// </summary>
        public DelegateCommand<NavigationItem> Selected { get; set; }
        /// <summary>
        /// 供外部Command绑定使用
        /// </summary>
        public ICommand Command { get => (ICommand)GetValue(CommandProperty); set => SetValue(CommandProperty, value); }
        /// <summary>
        /// 供外部CommandParameter绑定使用
        /// </summary>
        public string CommandParameter { get => (string)GetValue(CommandParameterProperty); set => SetValue(CommandParameterProperty, value); }



    }
}
